/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "stdafx.h"
#include "NewTon几何.h"

#include <ppl.h>
#include <矩阵.h>



S_NewTon长方体几何体::S_NewTon长方体几何体(S_NewTon核心* core, const vec3& ckg, float32 密度) {
	m_物理引擎枚举 = E_物理引擎::E_物理引擎_NewTon;
	m_Type = E_物理碰撞几何类型::E_碰撞几何_方体;
	m_Shape = NewtonCreateBox(core->m_物理世界, fabs(ckg.x), fabs(ckg.y), fabs(ckg.z), NULL, 0);
}



 



S_NewTon凸壳几何体::S_NewTon凸壳几何体(S_NewTon核心* core, const S_三角Mesh& v, float32 密度) {
	m_物理引擎枚举 = E_物理引擎::E_物理引擎_NewTon;
	m_Type = E_物理碰撞几何类型::E_碰撞几何_凸壳;
	
	uint32 num = v.m_vNum;

	Mat44f mat;
	f_构建单位矩阵(&mat);
	m_Shape = NewtonCreateConvexHull(core->m_物理世界, num, (float32*)v.m_vert, sizeof(vec3), 0.2f, 0, (float32*)&mat);
	//NewtonCollisionSetMode(m_Shape, 1);
	/*
	m_Points.resize(num);
	auto* r = m_Points.data();
	auto* p = v.m_vert;
	Concurrency::parallel_for<uint32>(0, num, [&](uint32 i) {
		r[i].x() = p[i].x;
		r[i].y() = p[i].y;
		r[i].z() = p[i].z;
	});*/
	
}






